package com.chuangshu.chuangshuteam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chuangshu.chuangshuteam.entity.TeamMember;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TeamMemberMapper extends BaseMapper<TeamMember> {

    /**
     * 根据用户ID查询团队成员信息（包含角色信息）
     */
    @Select("SELECT tm.*, r.name as role_name, r.description as role_description " +
            "FROM team_members tm " +
            "LEFT JOIN roles r ON tm.role_id = r.id " +
            "WHERE tm.user_id = #{userId} AND tm.team_id = #{teamId}")
    TeamMember selectWithRoleByUserId(@Param("userId") Long userId, @Param("teamId") Long teamId);
}